package org.socialresume.client.mvp.presenter;


import org.enunes.gwt.mvp.client.EventBus;
import org.enunes.gwt.mvp.client.presenter.BasePresenter;
import org.socialresume.client.model.Feed;
import org.socialresume.client.mvp.presenter.BodyPresenter.Display;

import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.inject.Inject;

public class BodyPresenterImpl extends BasePresenter<Display> implements BodyPresenter {
	
//	private MenuPresenter menuPresenter; 
	private FeedPresenter feedPresenter;
	
	@Inject
	public BodyPresenterImpl(EventBus eventBus, Display display, MenuPresenter menuPresenter, FeedPresenter feedPresenter) {
		super(eventBus, display);
//		this.menuPresenter =menuPresenter;
		this.feedPresenter =feedPresenter;
		display.addMenu(menuPresenter.getDisplay());
		display.addFeed(feedPresenter.getDisplay());
		bind();
	}
	
	@Override
	public void bind() {
		super.bind();
		registerHandler(eventBus.addHandler(SelectionEvent.getType(), new SelectionHandler<Feed>() {
			@Override
			public void onSelection(SelectionEvent<Feed> event) {
				showFeed(event.getSelectedItem());
			}
		}));
	}
	
	public void showFeed(Feed feed){
		feedPresenter.setFeed(feed);
	}

}
